

clear 

use "$P_Data_Processed/monthly_station_data_e5_merged.dta"

quietly reghdfe mean_price treat n_act_stations n_mkt_compet_adopt l_gdp pop_density med_age employed_share l_pop n_brand mean_temp sd_temp mean_precip sd_precip   if year<2019 , absorb(year_month StID) cluster(mktid) 
keep if e(sample)==1

sort StID year_month
by StID: keep if _n==1

keep StID 
save "$P_Data_Processed/active_StID.dta", replace 

******
******
******

clear 
use "$P_Data_Processed/cluster_mkts.dta"

merge 1:1 StID using "$P_Data_Processed/active_StID.dta"
keep if _merge==3
drop _merge

capture drop mkt_n_stations
by mktid, sort: gener mkt_n_stations = _N

** number of market types 
graph drop _all
preserve 
by mktid, sort: keep if _n==1
histogram mkt_n_stations, discrete freq color(gray) xtitle("Number of Stations per Market") ytitle("Total Number of Markets") xlabel(#21) name(c1_a)
gr export "$P_Figures/Figure_C1_a.eps", replace
restore 


histogram mkt_n_stations, discrete freq color(gray) xtitle("Number of Stations per Market") ytitle("Total Number of Stations") xlabel(#21) name(c1_b)
gr export "$P_Figures/Figure_C1_b.eps", replace


graph combine c1_a c1_b, iscale(1) xsize(10)

gr export "$P_Figures/Figure_C1.eps", replace 

